/**
 * 用户信息相关接口
 */
import type { GetTodayVipResult, LoginParams, LoginResult, SendCodeParams } from './type';
import { get, post } from '@/utils/request';
import type { UserState } from '@/store/modules/user/type';

enum URL {
  login = '/app/auth/login',
  sendCode = '/app/auth/sendCode',
  logout = '/app/user/logout',
  getProfile = '/app/user/getProfile',
  switchLogin = '/app/user/switchLogin',
  getConfigInfo = '/app/custCourse/configInfo',
  getTodayVip = '/app/rechargeStuVip/todayVip',
  getVipOrGzhStatus = '/app/rechargeStuVip/vipOrGzhStatus',
  getStudent = '/app/user/studentAccounts',
}

// 获取基础用户信息
export const getProfile = () => post<UserState>({ url: URL.getProfile });

// 用户登录
export const login = (data: LoginParams) => post<LoginResult>({ url: URL.login, data });

// 发送手机验证码
export const sendCode = (data: SendCodeParams) => post<any>({ url: URL.sendCode, data });

// 退出登录
export const logout = () => get<any>({ url: URL.logout });

// 切换账号登录
export const switchLogin = (data: { switchType: string; id: string }) => post<any>({ url: URL.switchLogin, data });

// 公共配置接口
export const getConfigInfo = () => get<any>({ url: URL.getConfigInfo });

// 今日是否是vip
export const getTodayVip = () => get<GetTodayVipResult>({ url: URL.getTodayVip });

// 是否已领取/已关注 type: 1-vip，2-公众号
export const getVipOrGzhStatus = (data: { type: string }) => post<any>({ url: URL.getVipOrGzhStatus, data });

// 刷新获取最新的学员列表
export const getStudent = () => post<LoginResult>({ url: URL.getStudent });
